Skip to content

feat: fixing transaction schema#207

Open
pengying wants to merge 1 commit intomainfrom
02-18-feat_fixing_transaction_schema
Open

feat: fixing transaction schema#207
pengying wants to merge 1 commit intomainfrom
02-18-feat_fixing_transaction_schema

Conversation

@pengying
Copy link
Contributor

@pengying pengying commented Feb 19, 2026

TL;DR

Fixed transaction schema inheritance by implementing proper polymorphic type handling for transactions.

What changed?

  • Removed the type property from the base Transaction schema to avoid conflicts when merging with child schemas
  • Added required type property with specific enum values to both IncomingTransaction and OutgoingTransaction schemas
  • Created a new TransactionOneOf schema that uses proper polymorphic discrimination between transaction types
  • Updated all API endpoints to reference TransactionOneOf instead of the base Transaction schema
  • Reorganized schema definitions for better clarity and proper inheritance

How to test?

  1. Verify that transaction-related API endpoints return the correct schema based on transaction type
  2. Confirm that the OpenAPI documentation correctly shows the discriminated transaction types
  3. Test both incoming and outgoing transaction flows to ensure proper type handling

Why make this change?

The previous schema structure had conflicting type definitions when the base Transaction schema was merged with specific transaction type schemas through allOf. This change implements proper polymorphic inheritance using the oneOf discriminator pattern, ensuring that transaction types are correctly differentiated and validated. This prevents potential issues with schema validation and improves API documentation clarity.

Copy link
Contributor Author

pengying commented Feb 19, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions
Copy link

github-actions bot commented Feb 19, 2026

✱ Stainless preview builds

This PR will update the grid SDKs with the following commit messages.

kotlin

feat(api): add type discriminators to transactions, union response types for operations

openapi

fix(types): add discriminated union to transfer-in/transfer-out/transactions responses

python

fix(types): update return types in transfer_in/transfer_out/transactions

typescript

feat(api): add response types to transferIn/transferOut/transactions methods

Edit this comment to update them. They will appear in their respective SDK's changelogs.

grid-openapi studio · code · diff

Your SDK built successfully.
generate ✅

grid-typescript studio · code · diff

Your SDK built successfully.
generate ✅build ✅lint ✅test ✅

npm install https://pkg.stainless.com/s/grid-typescript/adbbf1474a51b07d64d7e333cc76ac03a6a3774c/dist.tar.gz
grid-python studio · code · diff

Your SDK built successfully.
generate ✅build ✅lint ✅test ✅

pip install https://pkg.stainless.com/s/grid-python/ece14334fc984808e24319e48cadc258f1329f93/grid-0.0.1-py3-none-any.whl
grid-kotlin studio · code · diff

Your SDK built successfully.
generate ✅build ✅lint ✅test ✅

New diagnostics (7 note)
💡 Schema/EnumHasOneMember: This enum schema has just one member, so it could be defined using [`const`](https://json-schema.org/understanding-json-schema/reference/const).
💡 Schema/EnumHasOneMember: This enum schema has just one member, so it could be defined using [`const`](https://json-schema.org/understanding-json-schema/reference/const).
💡 Schema/EnumHasOneMember: This enum schema has just one member, so it could be defined using [`const`](https://json-schema.org/understanding-json-schema/reference/const).
💡 Schema/EnumHasOneMember: This enum schema has just one member, so it could be defined using [`const`](https://json-schema.org/understanding-json-schema/reference/const).
💡 Schema/EnumHasOneMember: This enum schema has just one member, so it could be defined using [`const`](https://json-schema.org/understanding-json-schema/reference/const).
💡 Schema/EnumHasOneMember: This enum schema has just one member, so it could be defined using [`const`](https://json-schema.org/understanding-json-schema/reference/const).
💡 Schema/EnumHasOneMember: This enum schema has just one member, so it could be defined using [`const`](https://json-schema.org/understanding-json-schema/reference/const).

This comment is auto-generated by GitHub Actions and is automatically kept up to date as you push.
If you push custom code to the preview branch, re-run this workflow to update the comment.
Last updated: 2026-02-19 22:01:01 UTC

@pengying pengying marked this pull request as ready for review February 19, 2026 01:05
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 19, 2026

Greptile Summary

This PR refactors transaction schema inheritance to properly handle polymorphic types using OpenAPI's oneOf discriminator pattern. The key changes include:

  • Created TransactionOneOf schema that uses oneOf discriminator to distinguish between IncomingTransaction and OutgoingTransaction
  • Added explicit type property with specific enum values (INCOMING/OUTGOING) to both transaction type schemas
  • Updated all API endpoints to reference TransactionOneOf instead of base Transaction schema
  • Added stainless config to remove type property from base Transaction schema to prevent allOf merge conflicts
  • Removed paymentInstructions from required fields in OutgoingTransaction (already flagged in previous review)

The refactoring improves OpenAPI schema validation and documentation clarity by properly implementing discriminated unions, though it does add a layer of indirection (TransactionOneOf → transaction types → base Transaction).

Confidence Score: 4/5

  • Safe to merge with minor caveats - schema refactoring is sound but has one already-flagged concern
  • The schema refactoring correctly implements OpenAPI polymorphism patterns and the stainless config appropriately handles type conflicts. However, the removal of paymentInstructions from required fields in OutgoingTransaction was already flagged in a previous review and remains unaddressed, which could be a breaking change for existing clients
  • Pay attention to openapi/components/schemas/transactions/OutgoingTransaction.yaml - the removal of paymentInstructions from required fields needs verification

Important Files Changed

Filename Overview
.stainless/stainless.yml Added stainless command to remove type property from Transaction base schema to prevent allOf conflicts
openapi/components/schemas/transactions/TransactionOneOf.yaml New schema using oneOf discriminator to properly distinguish between incoming and outgoing transactions
openapi/components/schemas/transactions/IncomingTransaction.yaml Added required type property with INCOMING enum value for proper polymorphic type handling
openapi/components/schemas/transactions/OutgoingTransaction.yaml Added required type property with OUTGOING enum; removed paymentInstructions from required (flagged in previous review)
openapi/paths/transactions/transactions.yaml Updated list endpoint to return TransactionOneOf instead of Transaction for proper type discrimination
openapi.yaml Compiled OpenAPI spec with all transaction schema changes and endpoint updates applied

Class Diagram

%%{init: {'theme': 'neutral'}}%%
classDiagram
    class Transaction {
        +string id
        +TransactionStatus status
        +string type
        +TransactionDestinationOneOf destination
        +string customerId
        +string platformCustomerId
        +datetime settledAt
        +datetime createdAt
        +datetime updatedAt
        +string description
    }
    
    class TransactionOneOf {
        <<oneOf>>
        discriminator: type
    }
    
    class IncomingTransaction {
        +string type = "INCOMING"
        +CurrencyAmount receivedAmount
        +TransactionSourceOneOf source
        +ReconciliationInstructions reconciliationInstructions
        +IncomingRateDetails rateDetails
        +IncomingTransactionFailureReason failureReason
    }
    
    class OutgoingTransaction {
        +string type = "OUTGOING"
        +CurrencyAmount sentAmount
        +CurrencyAmount receivedAmount
        +TransactionSourceOneOf source
        +number exchangeRate
        +int64 fees
        +string quoteId
        +PaymentInstructions[] paymentInstructions
        +Refund refund
        +OutgoingRateDetails rateDetails
        +OutgoingTransactionFailureReason failureReason
    }
    
    Transaction <|-- IncomingTransaction : extends via allOf
    Transaction <|-- OutgoingTransaction : extends via allOf
    TransactionOneOf *-- IncomingTransaction : discriminates
    TransactionOneOf *-- OutgoingTransaction : discriminates
    
    note for TransactionOneOf "API endpoints now reference\nTransactionOneOf instead of\nTransaction base schema"
    note for IncomingTransaction "type property added\nto required fields"
    note for OutgoingTransaction "type property added;\npaymentInstructions removed\nfrom required fields"
Loading

Last reviewed commit: 8ad3ce8

@pengying pengying force-pushed the 02-18-feat_fixing_transaction_schema branch from 2e13aea to 36ee105 Compare February 19, 2026 01:27
@pengying pengying force-pushed the 02-18-feat_fixing_transaction_schema branch from 36ee105 to c774ff0 Compare February 19, 2026 15:17
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

11 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

- $ref: ./Transaction.yaml
- type: object
required:
- type
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check that removing paymentInstructions from required fields is intentional and won't break existing clients

Prompt To Fix With AI
This is a comment left during a code review.
Path: openapi/components/schemas/transactions/OutgoingTransaction.yaml
Line: 5

Comment:
Check that removing `paymentInstructions` from required fields is intentional and won't break existing clients

How can I resolve this? If you propose a fix, please make it concise.

@pengying pengying force-pushed the 02-18-feat_fixing_transaction_schema branch from c774ff0 to eb98c72 Compare February 19, 2026 21:46
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

11 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment on lines 420 to 446
@@ -429,6 +430,20 @@ openapi:
# - "$.components.schemas.BusinessBeneficiary.allOf[1].properties"
# keys: [ "beneficiaryType" ]
# ── customerType: remove from base schemas ──
=======
# ── type: transaction base schema ──
- command: remove
reason: >-
Remove inline type enum from Transaction base schema to avoid
conflicting types when allOf merges with IncomingTransaction and
OutgoingTransaction which define type as single-value enums
args:
target:
- "$.components.schemas.Transaction.properties"
keys: [ "type" ]

# ── beneficiaryType: beneficiary schemas ──
>>>>>>> c774ff0 (feat: fixing transaction schema)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unresolved merge conflict will break the build

Suggested change
# ── type: transaction base schema ──
- command: remove
reason: >-
Remove inline type enum from Transaction base schema to avoid
conflicting types when allOf merges with IncomingTransaction and
OutgoingTransaction which define type as single-value enums
args:
target:
- "$.components.schemas.Transaction.properties"
keys: [ "type" ]
# ── beneficiaryType: beneficiary schemas ──
Prompt To Fix With AI
This is a comment left during a code review.
Path: .stainless/stainless.yml
Line: 420-446

Comment:
Unresolved merge conflict will break the build

```suggestion
    # ── type: transaction base schema ──
    - command: remove
      reason: >-
        Remove inline type enum from Transaction base schema to avoid
        conflicting types when allOf merges with IncomingTransaction and
        OutgoingTransaction which define type as single-value enums
      args:
        target:
          - "$.components.schemas.Transaction.properties"
        keys: [ "type" ]

    # ── beneficiaryType: beneficiary schemas ──
```

How can I resolve this? If you propose a fix, please make it concise.

@pengying pengying force-pushed the 02-18-feat_fixing_transaction_schema branch from eb98c72 to 8ad3ce8 Compare February 19, 2026 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments